package com.chcit.mobile.di.module;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.chcit.mobile.mvp.model.CommonModel;
import com.chcit.mobile.mvp.model.entity.ReceiveBean;
import com.chcit.mobile.mvp.model.entity.ShipmentBean;
import com.chcit.mobile.mvp.ui.adapter.ReceiveAdapter;
import com.chcit.mobile.mvp.ui.adapter.ShipmentAdapter;
import com.jess.arms.di.scope.FragmentScope;

import dagger.Module;
import dagger.Provides;

import com.chcit.mobile.mvp.contract.ShipmentContract;
import com.chcit.mobile.mvp.model.ShipmentModel;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Named;


@Module
public class ShipmentModule {
    private ShipmentContract.View view;

    /**
     * 构建ShipmentModule时,将View的实现类传进来,这样就可以提供View的实现类给presenter
     *
     * @param view
     */
    public ShipmentModule(ShipmentContract.View view) {
        this.view = view;
    }

    @FragmentScope
    @Provides
    ShipmentContract.View provideShipmentView() {
        return this.view;
    }

    @FragmentScope
    @Provides
    ShipmentContract.Model provideShipmentModel(ShipmentModel model) {
        return model;
    }

    @FragmentScope
    @Provides
    RecyclerView.LayoutManager provideLayoutManager() {
        return new LinearLayoutManager(view.getActivity());
    }

    @FragmentScope
    @Provides
    List<ShipmentBean> provideShipmentList(){
        return new ArrayList<>();
    }

    @FragmentScope
    @Provides
    ShipmentAdapter provideShipmentAdapter(List<ShipmentBean> shipmentBeans){
        return new ShipmentAdapter(shipmentBeans);
    }

    @FragmentScope
    @Named("common")
    @Provides
    CommonModel provideCommModel(CommonModel commModel) {
        return commModel;
    }
}